package j03exception;

import java.util.InputMismatchException;
import java.util.Scanner;

public class J2 {
    public static void main(String[] args) {
//        try {
//            System.out.println(10/0);
//            System.out.println("11111");
//        }catch (Exception e){
//            System.out.println("e = " + e);
//        }
        try {
            System.out.println(4/0);
        }catch (ArithmeticException e){
            System.out.println("e = " + e);
            //抛出详细的错误信息
//            e.printStackTrace();
        }

        System.out.println("=======");
        Scanner sc = new Scanner(System.in);
        System.out.print("输入数字：");
        try {
            int a = sc.nextInt();
        }catch (InputMismatchException e){
            System.out.println("e2 = " + e);
        }

        System.out.println("end");
    }
}


class Cat{
    int age = 6;
}
class J3{
    public static void main(String[] args) {
        int[] arr = {3,4};
        try {
            System.out.println(arr[100]);
        }catch (Exception e){
            e.printStackTrace();
        }
        System.out.println("===========");
        Cat cat = null;
        try {
            System.out.println(cat.age);
        }catch (NullPointerException e){
            e.printStackTrace();
        }


        System.out.println("==end===");



    }
}